package com.zscat.mallplus.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zscat.mallplus.annotation.IgnoreAuth;
import com.zscat.mallplus.dms.service.IDmsBannerService;
import com.zscat.mallplus.dms.service.IRoomService;
import com.zscat.mallplus.qsg.QsgRoom;
import com.zscat.mallplus.utils.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 首页轮播管理Controller
 */
@RestController
@Api(tags = "QsgBannerController", description = "首页轮播管理")
@RequestMapping("/api/dms/banner")
public class QsgBannerController {

    @Autowired
    private IDmsBannerService bannerService;

    @IgnoreAuth
    @GetMapping(value = "/list")
    @ApiOperation(value = "首页轮播列表")
    public Object list() {
        try {
            QueryWrapper qw = new QueryWrapper();
            qw.orderByAsc("orderby");
            qw.eq("is_zuoti",0);
            return new CommonResult().success(bannerService.list(qw));
        }catch (Exception e){
            e.printStackTrace();
            return new CommonResult().failed();
        }
    }

    @IgnoreAuth
    @GetMapping(value = "/listStore")
    @ApiOperation(value = "门店轮播列表")
    public Object listStore(Long storeId) {
        try {
            QueryWrapper qw = new QueryWrapper();
            qw.orderByAsc("orderby");
            qw.eq("is_zuoti",1);
            qw.eq("store_id",storeId);
            return new CommonResult().success(bannerService.list(qw));
        }catch (Exception e){
            e.printStackTrace();
            return new CommonResult().failed();
        }
    }
}
